


***  Title: Behind political affiliation: how moral values, identity politics, and party loyalty have affected COVID-19 vaccination


*************************************************************************************************
**#    1. PRELIMINARY SETTING   ***
*************************************************************************************************
*clear any data currently in Stata's memory 
 clear all

*set command interpreter to version 17
version 17

*tell Stata to run the entire do-file without pausing
set more off



*************************************************************************************************
**#    2. IMPORTING RAW DATA    ***
*************************************************************************************************

* Raw data are available upon request




*********************************************************************************
**#   3. GRAPHICAL ANALYSIS & SUMMARY STATISTICS   *****
*********************************************************************************
*** Number of counties by partisanship measure
. use ".\anti-vaxxer dataset - temporary.dta", clear

distinct fips //3099
fre rooted_partisanship if date1 == "31may2022"
bysort rooted_partisanship: distinct fips // 448, 458, 2193

fre partisanship_2020 if date1 == "31may2022"
bysort partisanship_2020: distinct fips //  456, 72, 74, 2497

bysort trumpist_county: distinct fips if rooted_partisanship == 3 // 686, 1507

bysort rep_majority_2020: distinct fips // 557, 2542


* -----------------------------------------------------------------------------
**# S1 Table.
// Descriptive statistics.

eststo clear
eststo allcounties:  estpost sum series_complete_pop_pct  relative_comm_1518 social_capita_index total_cases_rate total_deaths_rate pop_density prop_lessthan_HSedu prop_atleast_bachelor Unemployment_rate_2021 poverty_rate Median_HHIncome2020 internet_subsc median_age whitepop_percent blackpop_percent hispanicpop_percent health_insurance_rate if date1 == "31may2022"

eststo demcounties: estpost sum series_complete_pop_pct  relative_comm_1518 social_capita_index total_cases_rate total_deaths_rate pop_density prop_lessthan_HSedu prop_atleast_bachelor Unemployment_rate_2021 poverty_rate Median_HHIncome2020 internet_subsc median_age whitepop_percent blackpop_percent hispanicpop_percent health_insurance_rate if date1 == "31may2022" & rooted_partisanship ==1

eststo repcounties: estpost sum series_complete_pop_pct  relative_comm_1518 social_capita_index total_cases_rate total_deaths_rate pop_density prop_lessthan_HSedu prop_atleast_bachelor Unemployment_rate_2021 poverty_rate Median_HHIncome2020 internet_subsc median_age whitepop_percent blackpop_percent hispanicpop_percent health_insurance_rate if date1 == "31may2022" & rooted_partisanship ==3

esttab allcounties demcounties repcounties using ".\S1_table.tex",  main(mean) onecell aux(sd) label nodepvar compress replace b(3) mtitles( "All counties Mean (SD)" "Democrat counties Mean (SD)" "Republican counties Mean (SD)") addnotes( "Notes: mean coefficients; sd in parentheses; statistics for daily variables (Fully vaccinated people (%), 65+ vaccinated (%), total cases rate, and total deaths rate) are computed for the day 31may2022. Columns (2) and (3) refer to strongly Democrat and strongly Republican counties respectively. ") //  onecell


* -----------------------------------------------------------------------------
**# Figure 1.
* The daily proportion of fully vaccinated people and people who received at least one dose by 2000-2020 US party partisanship (by rooted_partisanship values) 

* Proportion of fully vaccinated people
. use ".\anti-vaxxer dataset - temporary.dta", replace

collapse (mean) series_complete_pop_pct, by (rooted_partisanship2000_20 date) 

twoway (line series_complete_pop_pct date if rooted_partisanship2000_20 == 3, lcolor(cranberry) ) ///
 (line series_complete_pop_pct date if rooted_partisanship2000_20 == 1, lcolor( dknavy) lpattern(dash)) /// 
 (line series_complete_pop_pct date if rooted_partisanship2000_20 == 2, lcolor(green) lpattern("--..") yli(0 20 40 60 80,  lc(gs12) lw(thin)) xlabel(, labsize(medsmall) angle(15)) name(rooted_full, replace) ytitle("Proportion of fully vaccinated people") xtitle("Date")  legend(order(1 "Safe Rep counties" 2 "Safe Dem counties" 3 "Swing counties")) ) 



* Proportion of people with at least of dose
. use ".\anti-vaxxer dataset - temporary.dta", replace

collapse (mean) administered_dose1_pop_pct, by (rooted_partisanship2000_20 date) 

twoway (line administered_dose1_pop_pct date if rooted_partisanship2000_20 == 3,   lcolor(cranberry)  ) /// 
(line administered_dose1_pop_pct date if rooted_partisanship2000_20 == 1,   lcolor( dknavy) lpattern(dash) ) /// 
(line administered_dose1_pop_pct date if rooted_partisanship2000_20 == 2, yli(0 20 40 60 80, lc(gs12) lw(thin)) xlabel(, labsize(medsmall) angle(15)) ylabel( none)   lcolor(green)  lpattern("--..") name(rooted_one, replace) ytitle("Population with at least one dose (in %)", height(5)) xtitle("Date")  legend(order(1 "Safe Rep counties" 2 "Safe Dem counties" 3 "Swing counties") size(small)) ) 

 grc1leg2 rooted_full rooted_one,  ycommon xcommon xtob1title ring(6) scheme(s1color)
 graph export ".\Figure 1.png", as(png) replace
 graph export ".\Figure 1.eps", as(eps) replace

 

* -----------------------------------------------------------------------------
**# Figure 2.
// Daily proportion of fully vaccinated people across Republican-leaning counties.

. use ".\anti-vaxxer dataset - temporary.dta", replace

gen trump_var =.
replace trump_var =1 if  rep_majority_2016==0 & rep_majority_2020 == 0 // =1 if Dem won in both 2016 and 2020 
replace trump_var=2 if trumpist_county==0 & rep_majority_2016==1 & rep_majority_2020 == 1 // =2 if Rep county but not trumpist
replace trump_var=3 if trumpist_county==1 // =3 if trumpist_county


collapse (mean) series_complete_pop_pct, by (trump_var date) 

* To get the diff in vaccinations between trumpist and non-trumpist
// drop if trump_var==.
// reshape wide series_complete_pop_pct, i(date) j(trump_var)


twoway ///
(line series_complete_pop_pct date if trump_var == 3, lcolor(cranberry)) ///
(line series_complete_pop_pct date if trump_var == 2, lcolor(red) lpattern(dash)) /// 
(line series_complete_pop_pct date if trump_var == 1, lcolor(dknavy) lpattern("--..")) ///
, yli(0 20 40 60 80, lc(gs12) lw(thin)) ///
xlabel( ///
    `=td(01jan2021)' "Jan 2021" ///
    `=td(01jul2021)' "Jul 2021" ///
    `=td(01jan2022)' "Jan 2022" ///
    `=td(01jun2022)' "Jun 2022", ///
    labsize(medsmall) angle(10) ///
) ///
name(rooted_full, replace) ///
ytitle("Proportion of fully vaccinated people") ///
xtitle("Date") ///
legend(order(1 "High-Trump-Support (Rep) counties" 2 "Non High-Trump-Support (Rep) counties" 3 "Dem counties") rows(3)) ///
scheme(s1color)



 graph export ".\Figure 2.png", as(png)  replace // name("Graph")
 graph export ".\Figure 2.eps", as(eps) replace
 
 



* -----------------------------------------------------------------------------
**# S1 Figure.


clear
set obs 24

* Generate a time series from November 2020 for 24 months
gen month = tm(2020m11) + _n - 1
format month %tm

* Create a numerical variable for y-axis (since strings cannot be used in varlist)
set seed 1234
gen y_value = runiformint(1, 26)

// Info from: https://en.wikipedia.org/wiki/COVID-19_vaccination_in_the_United_States
local date1 = tm(2020m12)  // December 2020
local date2 = tm(2021m4)  
// Info from: https://www.kff.org/coronavirus-covid-19/dashboard/kff-covid-19-vaccine-monitor-dashboard/
local date3 = tm(2021m5)  
local date4 = tm(2021m10)  
local date5 = tm(2021m11)  
local date6 = tm(2022m7)  
// Info from: https://en.wikipedia.org/wiki/COVID-19_vaccination_mandates_in_the_United_States#Federal_mandates
local date7 = tm(2021m9)

replace y_value = . if y_value == 7 & month != tm(2021m11)
replace y_value = . if y_value == 22 & month != tm(2021m10)
replace y_value = . if y_value == 25 & month != tm(2022m7)
replace y_value = . if y_value ==4

replace y_value = 4 if month == tm(2022m7)
replace y_value = 9 if month == tm(2021m10)
replace y_value = 8 if month == tm(2021m4)
replace y_value = 5.5 if month == tm(2021m9)

* Define the range of the x-axis using local macros for the month
local min_month = tm(2020m11)
local max_month = tm(2022m10)


* Create a scatter plot for the events
twoway (scatter y_value month if inlist(y_value, 6, 8, 5, 4, 7) | inlist(y_value, 9, 5.5), mcolor(blue) msize(small) aspectratio(.5)), ///  
        ytitle("") ///
       xtitle("Timeline") /// * title("Key COVID-19 Vaccine Monitor Events") *
       ylabel(none) ///  * Removes y-axis values *
       xlabel(, format(%tm) labsize(small)) ///  
       xscale(range(`min_month' `max_month')) yscale(range(3 (1) 12)) /// 
       legend(off) ///
xlabel(`=tm(2020m12)' "`tm(2020m12)'Dec 2020" `=tm(2021m3)' "`tm(2021m3)'Mar 2021" `=tm(2021m6)' "`tm(2021m6)'Jun 2021" `=tm(2021m9)' "`tm(2021m9)'Sep 2021" ///  
       `=tm(2021m12)' "`tm(2021m12)'Dec 2021" `=tm(2022m3)' "`tm(2022m3)'Mar 2022" `=tm(2022m6)' "`tm(2022m6)'Jun 2022" `=tm(2022m9)' "`tm(2022m9)'Sep 2022", ///  
       format(%tm) labsize(small) angle(20)) ///        
	   graphregion(color(white))  /// 
       yscale( lc(white)) ///  
       text(6 `date1' "{bf:Dec 2020:} The FDA grants emergency use" "authorization to the Pfizer–BioNTech and" "Moderna vaccines. Mass vaccinations begin.", place(ne) size(vsmall)) ///  
	   text(8 `date2' "{bf:Apr 2021:} All US states had opened" "vaccine eligibility to residents" "aged 16 and over.", place(e) size(vsmall)) /// 
	   text(5 `date3' "{bf:May 2021:} FDA authorizes vaccine" "for teenagers, 12-17", place(s) size(vsmall) )  ///
	   text(9 `date4' "{bf:Oct 2021:} FDA authorizes vaccines" "for kids, 5-11", place(e) size(vsmall))  ///
	   text(7 `date5' "{bf:Nov 2021:} The CDC begins recommending" "booster shots for all adults.", place(e) size(vsmall)) ///
	   text(4 `date6' "{bf:Jul 2022:} Following FDA authorization" "of vaccines for kids under 5", place(sw) size(vsmall)) ///
	   text(5.5 `date7' "{bf:Sept 2021:} Biden announces the Biden" "administration COVID-19 action plan," "effectively mandating vaccination for " "a large portion of the American workforce.", place(e)  size(vsmall)) 

	   
 graph export ".\S1 Figure.png", as(png) replace
 graph export ".\S1 Figure.eps", as(eps) replace









